package com.gimi.cloud.bbp.manage.consumer.service.mall.impl;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.gimi.cloud.bbp.common.enums.ResponseCodeEnum;
import com.gimi.cloud.bbp.common.utils.reqhead.Response;
import com.gimi.cloud.bbp.dto.mall.MallAppBannerGroupDTO;
import com.gimi.cloud.bbp.manage.consumer.feign.MallFeignService;
import com.gimi.cloud.bbp.manage.consumer.service.mall.MallBannerGroupService;

/**
 * APPBanner组管理相关接口实现类
 *
 * @author wbj
 * @version 1.0
 * @Description
 * @create 2018-01-30
 **/
@Service
public class MallBannerGroupServiceImpl implements MallBannerGroupService{
    private static final Logger logger = LoggerFactory.getLogger(MallBannerGroupServiceImpl.class);

    private MallFeignService mallFeignService;

    @Autowired
    public MallBannerGroupServiceImpl(MallFeignService mallFeignService) {
        this.mallFeignService = mallFeignService;
    }

    @Override
    public Response getBannerGroupList(HttpServletRequest request, HttpServletResponse response, MallAppBannerGroupDTO dto) throws Exception {
        return mallFeignService.getAppBannerGroupList(dto);
    }

    @Override
    public Response getBannerGroupInfo(HttpServletRequest request, HttpServletResponse response, MallAppBannerGroupDTO dto) throws Exception {
        if(null == dto.getAbgId()){
            Response resp = new Response();
            resp.setResponseCode(ResponseCodeEnum.NO_DATA,"Banner组id为空，获取Banner组列表失败");
            return resp;
        }
        return mallFeignService.getAppBannerGroupInfo(dto);
    }

    @Override
    public Response addBannerGroup(HttpServletRequest request, HttpServletResponse response, MallAppBannerGroupDTO dto) throws Exception {
        if(null != dto.getAbgId()){
            Response resp = new Response();
            resp.setResponseCode(ResponseCodeEnum.NO_DATA,"Banner组Id不为空，添加Banner组信息失败");
            return resp;
        }
        return mallFeignService.saveOrUpdateBannerGroup(dto);
    }

    @Override
    public Response editBannerGroup(HttpServletRequest request, HttpServletResponse response, MallAppBannerGroupDTO dto) throws Exception {
        if(null == dto.getAbgId()){
            Response resp = new Response();
            resp.setResponseCode(ResponseCodeEnum.NO_DATA,"Banner组Id为空，修改Banner组信息失败");
            return resp;
        }
        return mallFeignService.saveOrUpdateBannerGroup(dto);
    }

    @Override
    public Response deleteBannerGroup(HttpServletRequest request, HttpServletResponse response, MallAppBannerGroupDTO dto) throws Exception {
        if(null == dto.getAbgId()){
            Response resp = new Response();
            resp.setResponseCode(ResponseCodeEnum.NO_DATA,"Banner组Id为空，删除Banner组信息失败");
            return resp;
        }
        return mallFeignService.deleteBannerGroup(dto);
    }
}
